"factor(frame)none" = "Appeal Only",
'(Intercept)' = 'Constant'),
caption = "Effect of climate emissions frames on personal donation attitudes",
label = "tab:personal.donation",
include.rmse = FALSE,
include.constant = TRUE, # Ensure constant is included
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab2
# Write the LaTeX table to a file
writeLines(tab2, "MessagingFigsR/sec_reg_RR.tex")
# Determine unique variables across all private donations models
sec_unique_variables <- unique(unlist(lapply(sec_models, function(mod) grep("^factor\\(frame\\)", names(coef(mod)), value = TRUE))))
# Extract coefficients and standard errors for private donations models
sec_results_df <- extract_coefficients(sec_models, sec_unique_variables)
sec_results_df
sec_results_df$model <- c('main_j', 'main_s', 'dem_j', 'dem_s', 'rep_j', 'rep_s')
sec_results_df <- na.omit(sec_results_df)
sec_results_df$column_set <- factor(c('All', 'All', 'Democrats', 'Democrats', 'Republicans', 'Republicans'), levels = c("All", "Democrats", "Republicans"))
sec_results_df$coefficients <- as.numeric(sec_results_df$coefficients)
sec_results_df$standard_errors <- as.numeric(sec_results_df$standard_errors)
# Plot results for private donations
plot_results(
sec_results_df,
x_labels = c("main_j" = "Justice", "main_s" = "Solidarity", "dem_j" = "Justice", "dem_s" = "Solidarity", "rep_j" = "Justice", "rep_s" = "Solidarity"),
y_label = "Estimated Effect of Message Frame on Personal Donations",
colors = c("All" = 'purple3', 'Democrats' = 'blue3', 'Republicans' = 'red3'),
color_column = 'column_set',
file_path = "MessagingFigsR/sec_reg_RR.png"
)
# Define the variables for mechanisms
outcomes <- c("collective_guilt", "social_prox", "worriedwarming")
parties <- c('Democrat', 'Republican')
# Create an empty list to store regression results for mechanisms
reg_results <- list()
for (party in parties) {
party_data <- data[data$party_final_analysis == party, ]
for (outcome in outcomes) {
reg_model <- lm_robust(as.formula(paste(outcome, "~ factor(frame)")), party_data)
reg_results[[paste(outcome, party, sep = "_")]] <- reg_model
}
}
# Fit models for the entire sample for each outcome
collective_guilt_All <- lm_robust(collective_guilt ~ factor(frame), data)
social_prox_All <- lm_robust(social_prox ~ factor(frame), data)
worriedwarming_All <- lm_robust(worriedwarming ~ factor(frame), data)
# List of mechanism models
mech_models <- list(collective_guilt_All, reg_results$collective_guilt_Democrat, reg_results$collective_guilt_Republican,
social_prox_All, reg_results$social_prox_Democrat, reg_results$social_prox_Republican,
worriedwarming_All, reg_results$worriedwarming_Democrat, reg_results$worriedwarming_Republican)
mech_models2 <- list(collective_guilt_All, reg_results$collective_guilt_Democrat, reg_results$collective_guilt_Republican,
social_prox_All, reg_results$social_prox_Democrat, reg_results$social_prox_Republican)
mech_models3 <- list(worriedwarming_All, reg_results$worriedwarming_Democrat, reg_results$worriedwarming_Republican)
# Create the LaTeX table using the original models but overriding the standard errors and coefficients
tab3 <- texreg(mech_models2,
custom.model.names = c("Guilt Full", "Guilt D", "Guilt R", 'Proximity Full','Proximity D','Proximity R'),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
'(Intercept)' = 'Constant'),
caption = "Effect of message frame on collective guilt and social proximity",
label = "tab:mechanisms",
include.rmse = FALSE,
include.constant = TRUE, # Ensure constant is included
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab3
# Write the LaTeX table to a file
writeLines(tab3, "MessagingFigsR/mechanisms_RR.tex")
tab4 <- texreg(mech_models3,
custom.model.names = c("Worried All", "Worried D", "Worried R"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
'(Intercept)' = 'Constant'),
caption = "Effect of message frame on concern about global warming",
label = "tab:mechanisms_warming",
include.rmse = FALSE,
include.constant = TRUE, # Ensure constant is included
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab4
# Write the LaTeX table to a file
writeLines(tab3, "MessagingFigsR/app_mech_worry_RR.tex")
# Determine unique variables across all mechanism models
mech_unique_variables <- unique(unlist(lapply(mech_models, function(mod) grep("^factor\\(frame\\)", names(coef(mod)), value = TRUE))))
# Extract coefficients and standard errors for mechanism models using HC2 standard errors
mech_results_df <- extract_coefficients(mech_models, mech_unique_variables)
mech_results_df$model <- c('guilt a j', 'guilt a s', 'guilt d j','guilt d s','guilt r j','guilt r s',
'prox a j','prox a s','prox d j','prox d s','prox r j','prox r s',
'worry a j','worry a s','worry d j','worry d s','worry r j','worry r s')
# Clean up the results data frame for mechanisms
mech_results_df <- na.omit(mech_results_df)
mech_results_df$column_set <- factor(c('Collective Guilt- Justice','Collective Guilt- Justice','Collective Guilt- Justice','Collective Guilt- Justice','Collective Guilt- Justice','Collective Guilt- Justice',
'Social Proximity- Solidarity','Social Proximity- Solidarity','Social Proximity- Solidarity','Social Proximity- Solidarity','Social Proximity- Solidarity','Social Proximity- Solidarity',
'Concern over Global Warming','Concern over Global Warming','Concern over Global Warming','Concern over Global Warming','Concern over Global Warming','Concern over Global Warming'),
levels = c('Collective Guilt- Justice','Social Proximity- Solidarity','Concern over Global Warming'))
mech_results_df$party <- c('All','All','Democrats','Democrats','Republicans','Republicans',
'All','All','Democrats','Democrats','Republicans','Republicans',
'All','All','Democrats','Democrats','Republicans','Republicans')
mech_results_df$coefficients <- as.numeric(mech_results_df$coefficients)
mech_results_df$standard_errors <- as.numeric(mech_results_df$standard_errors)
# Remove unnecessary models and columns
mech_results_df <- mech_results_df[!(mech_results_df$model %in% c('guilt a s','guilt d s','guilt r s','prox a j','prox d j','prox r j')), ]
mech_results_df <- mech_results_df[!(mech_results_df$column_set == 'Concern over Global Warming'),]
plot_results(
mech_results_df,
x_labels = c("guilt d j" = "", "guilt a j" = "", "guilt d s" = "Solidarity", "guilt r j" = "", "guilt r s" = "Solidarity",
"prox d j" = "Justice", "prox d s" = "", "prox a s" = "", "prox r j" = "Justice", "prox r s" = "",
"worry a j" = "Justice", "worry a s" = "Solidarity", "worry d j" = "Justice", "worry d s" = "Solidarity",
"worry r j" = "Justice", "worry r s" = "Solidarity"),
y_label = "Estimated Effect of Message Frame on Attitudes",
color_column = 'party',
colors = c('All'= 'purple','Democrats' = 'blue3', 'Republicans' = 'red3'),
file_path = "MessagingFigsR/mechanisms_RR.png"
)
# Compute results table for t-tests
control_group <- subset(data, factor(frame) == 'none')
control_group$group <- ifelse(control_group$white == 1, "White",
ifelse(control_group$black == 1, "Black", NA))
t_test_message_main <- t.test(message_main ~ group, data = control_group, subset = !is.na(group))
t_test_c_donate_1 <- t.test(c_donate_1 ~ group, data = control_group, subset = !is.na(group))
results_table <- create_results_table(t_test_message_main, t_test_c_donate_1, control_group)
colnames(results_table) <- c("Outcome", "Mean Difference", "t Statistic", "p-value", "95% CI Lower", "95% CI Upper", "Mean Black", "Mean White")
latex_table <- xtable(results_table, caption = "Generosity Comparison Control Blacks vs. Whites", label = "tab:control.generosity")
# Alternatively, save the table to a .tex file
writeLines(print(latex_table, include.rownames = FALSE), "MessagingFigsR/control_generosity_RR.tex")
#Main with covariates
main_lm_c1 <- lm_robust(message_main ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + education + foreigntreat + racetreat, data = data)
main_lm_c2 <- lm_robust(message_main ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = data)
main_lm_c1_dems <- lm_robust(message_main ~ factor(frame) + birth_year + female + income_scale + education + foreigntreat + racetreat, data = dems)
main_lm_c1_reps <- lm_robust(message_main ~ factor(frame) + birth_year + female + income_scale + education + foreigntreat + racetreat, data = reps)
main_lm_c2_dems <- lm_robust(message_main ~ factor(frame) + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = dems)
main_lm_c2_reps <- lm_robust(message_main ~ factor(frame) + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = reps)
models <- list(main_lm_c1, main_lm_c2, main_lm_c1_dems, main_lm_c2_dems,
main_lm_c1_reps, main_lm_c2_reps)
tab5 <- texreg(models,
custom.model.names = c("Covariates 1", "Covariates 2", "Dem Covariates 1", "Dem Covariates 2", "Rep Covariates 1", "Rep Covariates 2"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
"party_final_analysisRepublican" = "Republican Party",
"party_final_analysisOther" = "Other Party",
"birth_year" = 'Birth Year', 'female' = 'Female', 'income_scale' = 'Income',
'white' = 'White', 'black' = 'Black', 'education' = 'Education',
'weather_shock' = 'Weather Shock', 'heat_shock' = 'Heat Shock',
'racetreat' = 'Race Treatment', 'foreigntreat' = 'Foreign Treatment', 'thermom_black' = 'Attitudes Black',
'thermom_othercountry' = 'Attitudes Other Country', 'travel_gs' = 'Travel Global South',
'c_out_orient_index' = 'Outward Orientation',
'(Intercept)' = 'Constant'),
caption = "Effect of climate emissions frames on Aid Support Index, with covariates",
label = "tab:main.controls",
include.rmse = FALSE,
include.constant = TRUE, # Ensure constant is included
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab5
writeLines(tab5, "MessagingFigsR/app_covars_main_RR.tex")
unique_variables <- unique(unlist(lapply(models, function(mod) grep("^factor\\(frame\\)", names(coef(mod)), value = TRUE))))
# Extract the coefficients and standard errors
results <- extract_coefficients(models, unique_variables)
results <- na.omit(results)
results$model <- c('cov1 j','cov1 s','cov2 j','cov2 s','d cov1 j','d cov1 s','d cov2 j','d cov2 s',
'r cov1 j','r cov1 s','r cov2 j','r cov2 s')
results$model <- factor(results$model, levels = c('cov1 s','cov2 s','cov1 j','cov2 j','d cov1 s','d cov2 s','d cov1 j','d cov2 j',
'r cov1 s','r cov2 s','r cov1 j','r cov2 j'))
results$column_set <- c('All','All','All','All',
'Democrats','Democrats','Democrats','Democrats','Republicans','Republicans','Republicans','Republicans')
results$column_set <- factor(results$column_set, levels = c("All", "Democrats", "Republicans"))
results$coefficients <- as.numeric(results$coefficients)
results$standard_errors <- as.numeric(results$standard_errors)
x_labels <- c("cov1 s" = "Solidarity",
"cov2 s" = "Solidarity*",
"cov1 j" = "Justice",
"cov2 j" = "Justice*",
"d cov1 s" = "Solidarity",
"d cov2 s" = "Solidarity*",
"d cov1 j" = "Justice",
"d cov2 j" = "Justice*",
"r cov1 s" = "Solidarity",
"r cov2 s" = "Solidarity*",
"r cov1 j" = "Justice",
"r cov2 j" = "Justice*")
# Plot the results
plot_results(results, x_labels, "Estimated Effect of climate emissions frames on Aid Support Index", c("All" = 'purple3', 'Democrats'= 'blue3', 'Republicans' = 'red3'),
"MessagingFigsR/app_covars_main_RR.png", "column_set")
#Donations
sec_lm_c1 <- lm_robust(c_donate_1 ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + education + foreigntreat + racetreat, data = data)
sec_lm_c2 <- lm_robust(c_donate_1 ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = data)
#regression analysis by party
sec_lm_c1_dems <- lm_robust(c_donate_1 ~ factor(frame) + birth_year + female + income_scale + education + foreigntreat + racetreat, data = dems)
sec_lm_c1_reps <- lm_robust(c_donate_1 ~ factor(frame) + birth_year + female + income_scale + education + foreigntreat + racetreat, data = reps)
sec_lm_c2_dems <- lm_robust(c_donate_1 ~ factor(frame) + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = dems)
sec_lm_c2_reps <- lm_robust(c_donate_1 ~ factor(frame) + birth_year + female + income_scale + white + black + education + weather_shock + heat_shock + thermom_black + thermom_othercountry + foreigntreat + racetreat + c_out_orient_index + travel_gs, data = reps)
models <- list(sec_lm_c1, sec_lm_c2, sec_lm_c1_dems, sec_lm_c2_dems,
sec_lm_c1_reps, sec_lm_c2_reps)
tab6 <- texreg(models,
custom.model.names = c("Covariates 1", "Covariates 2", "Dem Covariates 1", "Dem Covariates 2", "Rep Covariates 1", "Rep Covariates 2"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
"party_final_analysisRepublican" = "Republican Party",
"party_final_analysisOther" = "Other Party",
"birth_year" = 'Birth Year', 'female' = 'Female', 'income_scale' = 'Income',
'white' = 'White', 'black' = 'Black', 'education' = 'Education',
'weather_shock' = 'Weather Shock', 'heat_shock' = 'Heat Shock',
'racetreat' = 'Race Treatment', 'foreigntreat' = 'Foreign Treatment', 'thermom_black' = 'Attitudes Black',
'thermom_othercountry' = 'Attitudes Other Country', 'travel_gs' = 'Travel Global South',
'c_out_orient_index' = 'Outward Orientation',
'(Intercept)' = 'Constant'),
caption = "Effect of climate emissions frames on personal donation attitudes, with covariates",
label = "tab:sec.controls",
include.rmse = FALSE,
include.constant = TRUE, # Ensure constant is included
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab6
writeLines(tab6, "MessagingFigsR/app_covars_sec_RR.tex")
# Get the unique variables across all models
unique_variables <- unique(unlist(lapply(models, function(mod) grep("^factor\\(frame\\)", names(coef(mod)), value = TRUE))))
# Extract the coefficients and standard errors
results <- extract_coefficients(models, unique_variables)
results <- na.omit(results)
results$model <- c('cov1 j','cov1 s','cov2 j','cov2 s','d cov1 j','d cov1 s','d cov2 j','d cov2 s',
'r cov1 j','r cov1 s','r cov2 j','r cov2 s')
results$model <- factor(results$model, levels = c('cov1 s','cov2 s','cov1 j','cov2 j','d cov1 s','d cov2 s','d cov1 j','d cov2 j',
'r cov1 s','r cov2 s','r cov1 j','r cov2 j'))
results$column_set <- c('All','All','All','All',
'Democrats','Democrats','Democrats','Democrats','Republicans','Republicans','Republicans','Republicans')
results$column_set <- factor(results$column_set, levels = c("All", "Democrats", "Republicans"))
results$coefficients <- as.numeric(results$coefficients)
results$standard_errors <- as.numeric(results$standard_errors)
x_labels <- c("cov1 s" = "Solidarity",
"cov2 s" = "Solidarity*",
"cov1 j" = "Justice",
"cov2 j" = "Justice*",
"d cov1 s" = "Solidarity",
"d cov2 s" = "Solidarity*",
"d cov1 j" = "Justice",
"d cov2 j" = "Justice*",
"r cov1 s" = "Solidarity",
"r cov2 s" = "Solidarity*",
"r cov1 j" = "Justice",
"r cov2 j" = "Justice*")
# Plot the results
plot_results(results, x_labels, "Estimated Effect of climate emissions frames on Personal Donations", c("All" = 'purple3', 'Democrats'= 'blue3', 'Republicans' = 'red3'),
"MessagingFigsR/app_covars_sec_RR.png", "column_set")
# WITH INTERACTION TERMS
data_noOther <- data[data$party_final_analysis != 'Other',]
table(data_noOther$party_final_analysis)
main_lm_partyI <- lm_robust(message_main ~ factor(frame) + party_final_analysis*factor(frame), data = data_noOther)
sec_lm_partyI <- lm_robust(c_donate_1 ~ factor(frame) + party_final_analysis*factor(frame), data = data_noOther)
summary(main_lm_partyI)
summary(sec_lm_partyI)
tab6 <- texreg(list(main_lm_partyI, sec_lm_partyI),
custom.model.names=c("Main Outcome", "Donations Outcome"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
"party_final_analysisRepublican" = "Republican Party",
"party_final_analysisOther" = "Other Party",
"factor(frame)blame:party_final_analysisRepublican" = 'Interaction: Justice Republican',
"factor(frame)blame:party_final_analysisOther" ='Interaction: Justice Other',
"factor(frame)global:party_final_analysisRepublican"='Interaction: Solidarity Republican',
"factor(frame)global:party_final_analysisOther" = 'Interaction: Solidarity Other',
'(Intercept)' = 'Constant'),
caption="Estimated Effect of climate emissions frames on Aid Support Index and personal donation attitudes with party interaction term",
label="tab:party.interaction",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab6
writeLines(tab6,"MessagingFigsR/app_party_int_RR.tex")
pres_lm <- lm_robust(president ~ factor(frame), data = data)
pres_lm_d <- lm_robust(president ~ factor(frame), data = dems)
pres_lm_r <- lm_robust(president ~ factor(frame), data = reps)
help_lm <- lm_robust(us_help ~ factor(frame), data = data)
help_lm_d <- lm_robust(us_help ~ factor(frame), data = dems)
help_lm_r <- lm_robust(us_help ~ factor(frame), data = reps)
pres <- texreg(list(pres_lm, pres_lm_d, pres_lm_r),
custom.model.names=c("Presidential", "Presidential D", "Presidential R"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",'(Intercept)' = 'Constant'
),
caption="Estimated Effect of climate emissions frames on Presidential Pledge Donations (part of Aid Support Index)",
label="tab:pres.only",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
pres
writeLines(pres,"MessagingFigsR/app_pres_only_RR.tex")
help <- texreg(list(help_lm, help_lm_d, help_lm_r),
custom.model.names=c("US Aid", "US Aid D", "US Aid R"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",'(Intercept)' = 'Constant'
),
caption="Estimated Effect of climate emissions frames on support for US Assistance (part of Aid Support Index)",
label="tab:help.only",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
help
writeLines(help,"MessagingFigsR/app_usaid_only_RR.tex")
##WHITE ONLY
# main reg
white <- subset(data, white == 1)
black <- subset(data, black == 1)
demsW <- subset(white, party_final_analysis == 'Democrat')
repsW <- subset(white, party_final_analysis == 'Republican')
demsB <- subset(black, party_final_analysis == 'Democrat')
repsB <- subset(black, party_final_analysis == 'Republican')
white_lm <- lm_robust(message_main ~ factor(frame), data = white)
white_lm_dems <- lm_robust(message_main ~ factor(frame), data = demsW)
white_lm_reps <- lm_robust(message_main ~ factor(frame), data = repsW)
black_lm <- lm_robust(message_main ~ factor(frame), data = black)
black_lm_dems <- lm_robust(message_main ~ factor(frame), data = demsB)
black_lm_reps <- lm_robust(message_main ~ factor(frame), data = repsB)
white <- texreg(list(white_lm, white_lm_dems,
white_lm_reps),
custom.model.names=c("White", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only", '(Intercept)' = 'Constant'),
caption="Effect of climate emissions frames on Aid Support Index, white respondents",
label="tab:main.white",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
white
writeLines(white,"MessagingFigsR/app_main_white_RR.tex")
black <- texreg(list(black_lm, black_lm_dems,
black_lm_reps),
custom.model.names=c("Black", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only", '(Intercept)' = 'Constant'),
caption="Effect of climate emissions frames on Aid Support Index, black respondents",
label="tab:main.black",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
black
writeLines(black,"MessagingFigsR/app_main_black_RR.tex")
process_data_main <- function(data, dems, reps, data_name, name) {
# Initial releveling and model fitting
main_lm <- lm_robust(message_main ~ factor(frame), data = data)
main_lm_covars <- lm_robust(message_main ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + education + foreigntreat + racetreat, data = data)
main_lm_dems <- lm_robust(message_main ~ factor(frame), data = dems)
main_lm_reps <- lm_robust(message_main ~ factor(frame), data = reps)
# Collect models for table creation
models <- list(main_lm, main_lm_covars, main_lm_dems, main_lm_reps)
# Create regression table
tab <- texreg(models,
custom.model.names = c("Main", "Covariate", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
"party_final_analysisRepublican" = "Republican Party",
"party_final_analysisOther" = "Other Party",
"birth_year" = "Birth Year", 'female' = 'Female',
'white' = 'White', 'black' = 'Black', 'education' = 'Education',
'weather_shock' = 'Weather Shock', 'heat_shock' = 'Heat Shock',
'racetreat' = 'Race Treatment', 'income_scale' = 'Income','foreigntreat' = 'Foreign Treatment',
'c_out_orient_index' = 'Outward Orientation', '(Intercept)' = 'Constant'),
caption = paste("Effect of climate emissions frames on Aid Support Index,",name),
label = paste0("tab:main_", data_name),
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
paste('Main',data_name)
tab
# Save regression table
writeLines(tab, paste0("MessagingFigsR/app_main_", data_name, ".tex"))
return(models)
}
process_data_sec <- function(data, dems, reps, data_name, name) {
main_lm <- lm_robust(c_donate_1 ~ factor(frame), data = data)
main_lm_covars <- lm_robust(c_donate_1 ~ factor(frame) + party_final_analysis + birth_year + female + income_scale + education + foreigntreat + racetreat, data = data)
main_lm_dems <- lm_robust(c_donate_1 ~ factor(frame), data = dems)
main_lm_reps <- lm_robust(c_donate_1 ~ factor(frame), data = reps)
# Collect models for table creation
models <- list(main_lm, main_lm_covars, main_lm_dems, main_lm_reps)
# Create regression table
tab <- texreg(models,
custom.model.names = c("Main", "Covariate", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
"party_final_analysisRepublican" = "Republican Party",
"party_final_analysisOther" = "Other Party",
"birth_year" = "Birth Year", 'female' = 'Female',
'white' = 'White', 'black' = 'Black', 'education' = 'Education',
'weather_shock' = 'Weather Shock', 'heat_shock' = 'Heat Shock',
'racetreat' = 'Race Treatment', 'income_scale' = 'Income','foreigntreat' = 'Foreign Treatment',
'c_out_orient_index' = 'Outward Orientation', '(Intercept)' = 'Constant'),
caption = paste("Effect of climate emissions frames on personal donation attitudes,", name),
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
paste('Sec',data_name)
tab
# Save regression table
writeLines(tab, paste0("MessagingFigsR/app_sec_", data_name, ".tex"))
return(models)
}
data_quality_attn <- data[data$Q1 == 'The Drudge Report,ABC News website',] #&
# data$f_attcheck_ad == 'Somewhat agree',] #&
data_quality_attn_dems <- dems[dems$Q1 == 'The Drudge Report,ABC News website',]# &
# dems$f_attcheck_ad == 'Somewhat agree',]
data_quality_attn_reps <- reps[reps$Q1 == 'The Drudge Report,ABC News website',]# &
data_quality_prog <- data[data$Progress == 100,]
data_quality_prog_dems <- dems[dems$Progress == 100,]
data_quality_prog_reps <- reps[reps$Progress == 100,]
# Then, filter based on 'Duration' being more than 1/3 of the median
data_quality_median <- data[data$`Duration (in seconds)` > (median(data$`Duration (in seconds)`) / 3), ]
data_quality_median_dems <- dems[dems$`Duration (in seconds)` > (median(dems$`Duration (in seconds)`) / 3), ]
data_quality_median_reps <- reps[reps$`Duration (in seconds)` > (median(reps$`Duration (in seconds)`) / 3), ]
# Finally, filter out rows where 'c_moral_ad', 'c_toomuchtalk_ad', 'c_moresimilar_ad', 'c_worried_ad' are equal
data_quality_battery <- data[!(data$c_moral_ad == data$c_toomuchtalk_ad &
data$c_toomuchtalk_ad == data$c_moresimilar_ad &
data$c_moresimilar_ad == data$c_worried_ad), ]
data_quality_battery_dems <- dems[!(dems$c_moral_ad == dems$c_toomuchtalk_ad &
dems$c_toomuchtalk_ad == dems$c_moresimilar_ad &
dems$c_moresimilar_ad == dems$c_worried_ad), ]
data_quality_battery_reps <- reps[!(reps$c_moral_ad == reps$c_toomuchtalk_ad &
reps$c_toomuchtalk_ad == reps$c_moresimilar_ad &
reps$c_moresimilar_ad == reps$c_worried_ad), ]
process_data_main(data_quality_attn, data_quality_attn_dems, data_quality_attn_reps, 'attention_check', 'Both Attention Checks')
process_data_sec(data_quality_attn, data_quality_attn_dems, data_quality_attn_reps, 'attention_check', 'Both Attention Checks')
process_data_main(data_quality_battery,data_quality_battery_dems,data_quality_battery_reps, 'straightline', 'No Straightline')
process_data_sec(data_quality_battery,data_quality_battery_dems,data_quality_battery_reps, 'straightline', 'No Straightline')
process_data_main(data_quality_median,data_quality_median_dems,data_quality_median_reps, 'median', 'Not below 1/3 Median Response Time')
process_data_sec(data_quality_median,data_quality_median_dems,data_quality_median_reps, 'median', 'Not below 1/3 Median Response Time')
process_data_main(data_quality_prog,data_quality_prog_dems,data_quality_prog_reps, 'progress', 'Completed Survey')
process_data_sec(data_quality_prog,data_quality_prog_dems,data_quality_prog_reps, 'progress', 'Completed Survey')
# Outcomes with solidarity base
# Relevel the frame variable
data$frame_rl <- relevel(data$frame, ref = "global")
dems$frame_rl <- relevel(dems$frame, ref = "global")
reps$frame_rl <- relevel(reps$frame, ref = "global")
# Main regression models
main_lm <- lm_robust(message_main ~ factor(frame_rl), data = data)
main_lm_dems <- lm_robust(message_main ~ factor(frame_rl), data = dems)
main_lm_reps <- lm_robust(message_main ~ factor(frame_rl), data = reps)
# LaTeX table for main models only
tab <- texreg(list(main_lm, main_lm_dems, main_lm_reps),
custom.model.names = c("Main", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame_rl)blame" = "Climate Justice",
"factor(frame_rl)global" = "Global Solidarity",
"factor(frame_rl)none" = "Appeal Only", '(Intercept)' = 'Constant'),
caption = "Effect of climate emissions frames on Aid Support Index, compared to Global Solidarity Treatment",
label = "tab:relevel.aid",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab
writeLines(tab, "MessagingFigsR/app_main_solidarity_RR.tex")
# Main regression models without controls for private donations
sec_lm <- lm_robust(c_donate_1 ~ factor(frame_rl), data = data)
sec_lm_dems <- lm_robust(c_donate_1 ~ factor(frame_rl), data = dems)
sec_lm_reps <- lm_robust(c_donate_1 ~ factor(frame_rl), data = reps)
# LaTeX table for main models only
tab2 <- texreg(list(sec_lm, sec_lm_dems, sec_lm_reps),
custom.model.names = c("Main", "Democrats", "Republicans"),
custom.coef.map = list("factor(frame_rl)blame" = "Climate Justice",
"factor(frame_rl)global" = "Global Solidarity",
"factor(frame_rl)none" = "Appeal Only", '(Intercept)' = 'Constant'),
caption = "Effect of climate emissions frames on personal donation attitudes, compared to Global Solidarity Treatment",
label = "tab:relevel.personal.donation",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab2
writeLines(tab2, "MessagingFigsR/app_sec_solidarity_RR.tex")
#Thermom Q for H5
data$solidarity <- ifelse(data$frame == 'global',1,0)
main_lm_thermom <- lm_robust(message_main ~ solidarity + thermom_oc_index + thermom_oc_index*solidarity, data = data)
sec_lm_thermom <- lm_robust(c_donate_1 ~ solidarity + thermom_oc_index + thermom_oc_index*solidarity, data = data)
summary(main_lm_thermom)
tab4 <- texreg(list(main_lm_thermom,sec_lm_thermom),
custom.model.names = c("Main", "Secondary"),
custom.coef.map = list("factor(frame)blame" = "Climate Justice",
"factor(frame)global" = "Global Solidarity",
"factor(frame)none" = "Appeal Only",
'solidarity' = 'Global Solidarity',
"thermom_oc_index" = "Thermom Other Country",
"factor(frame)blame:thermom_oc_index" = 'Interaction: Justice',
"solidarity:thermom_oc_index" = 'Interaction: Solidarity', '(Intercept)' = 'Constant'),
caption = "Effect of climate treatment on personal donation attitudes",
label = "tab:personal.donation",
include.rmse = FALSE,
include.ci = FALSE,
stars = c(0.01, 0.05, 0.1),
float.pos = "h")
tab4
writeLines(tab4, "MessagingFigsR/app_H5_reg_RR.tex")
